﻿using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Sasa.QualityTools.CodeAnalysis.Core.Views;
using Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Properties;
using Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.ViewModels;
using System;
using System.ComponentModel.Design;
using System.Runtime.InteropServices;

namespace Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Views
{
    [Guid("33671D93-FEC5-4FF6-B769-3CA0934F4F75")]
    public class RuleDetailWindowPane : ToolWindowPane, IRuleDetailView
    {
        public object DataContext
        {
            get
            {
                return ((RuleDetailContent)Content).DataContext;
            }
            set
            {
                ((RuleDetailContent)Content).DataContext = value;
            }
        }


        public RuleDetailWindowPane()
        {
            Caption = Resources.RuleDetailWindowTitle;
            BitmapResourceID = 301;
            BitmapIndex = 0;
            ToolBar = new CommandID(new Guid(Constants.RuleDetailWindowPane.Id), Constants.RuleDetailWindowPane.Toolbar);

            var content = new RuleDetailContent();
            content.DataContext = new RuleDetailViewModel();
            Content = content;
        }


        public void Show()
        {
            var frame = (IVsWindowFrame)Frame;
            ErrorHandler.ThrowOnFailure(frame.Show());
        }

        public void Close()
        {
            var frame = (IVsWindowFrame)Frame;
            ErrorHandler.ThrowOnFailure(frame.Hide());
        }
    }
}
